#include "mt3d_cuda.h"

void mt3d::run(int argc, char *argv[])
{
    // Read configuration
    read_config(argv[1]);

    if (modeling_only_)
    {
        // Read Tetgen model
        read_model(tetgen_file_);
        // save Gmsh model
        save_model(tetgen_file_, false);
    }
    else
    {
        // Read Tetgen model
        read_model(tetgen_file_);
        // Prepare the linear system A
        assemble_linear_system();
        // Apply boundary condition
        apply_boundary_condition();
        // Solve the linear system
        solve();
        // Calculate observations
        post_process();
        // save Gmsh model
        save_model(tetgen_file_, true);
        // save observations
        save_observation(tetgen_file_);
    }
    return;
}

int main(int argc, char *argv[]) try
{
    if (argc <= 1)
    {
        std::cerr << "Usage: ./mt3d <config-file>\n";
        return -1;
    }
    
    mt3d mt;
    mt.run(argc, argv);
    return 0;
}
catch (std::exception &e)
{
    GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
}